#include "Vector.hpp"

Vector::Vector( unsigned int m, unsigned int n ) :
	Matrix( m, n )
{
	if( m > 1 && n > 1 )
		throw std::logic_error( (char*)"Dimensiones del vector incorrectas" );

	_isColumn = ( m > 1 );
}

Vector::Vector( unsigned int n ) :
	Matrix( n, 1 )
{
	_isColumn = true;	
}

Vector::Vector( const Vector& v ) :
	Matrix( v )
{
	_isColumn = v._isColumn;
}

Vector::Vector( const Matrix& m ) :
	Matrix( m )
{
	if( m.rows() > 1 && m.cols() > 1 )
		throw std::logic_error( (char*)"La matriz no es un vector" );

	_isColumn = ( m.rows() > 1 );
}

Vector::~Vector()
{

}

double& Vector::operator[]( unsigned int i )
{
	if( _isColumn )
		return _matrix[i-1][0];
	else
		return _matrix[0][i-1];
}

const double Vector::operator[]( unsigned int i ) const
{
	if( _isColumn )
		return _matrix[i-1][0];
	else
		return _matrix[0][i-1];
}

double& Vector::operator()( unsigned int i )
{
	return this->operator[](i);
}

const double Vector::operator()( unsigned int i ) const
{
	return this->operator[](i);
}

Vector Vector::transposed() const
{
	return Matrix::transposed();
}

std::istream& Vector::read( std::istream& in )
{
	return Matrix::read( in );
}

